﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Model;

namespace BLL
{
    public class PercentService
    {
        DAL.PercentDAL percentdal = new DAL.PercentDAL();

        /// <summary>
        /// 根据模型来更新数据
        /// </summary>
        /// <param name="model">百分比实体</param>
        /// <returns>返回bool值</returns>
        public bool update(BoPercent model)
        {
            return percentdal.update(model) > 0;
        }

        /// <summary>
        /// 根据实体来插入一条数据
        /// </summary>
        /// <param name="model">实体</param>
        /// <returns>返回bool值</returns>
        public bool insert(BoPercent model)
        {
            model.PER_ID = Guid.NewGuid().ToString();
            return percentdal.insert(model)>0;
        }

        /// <summary>
        /// 根据条件来获取视图列表
        /// </summary>
        /// <param name="ConStr">条件</param>
        /// <returns>返回相应的对象列表</returns>
        public IList<BoPercent> Getv_Participant(string ConStr)
        {
            return percentdal.Getv_Participant(ConStr);
        }

        /// <summary>
        /// 根据id来获取相应的实体
        /// </summary>
        /// <param name="PercentId">id</param>
        /// <returns>返回实体</returns>
        public BoPercent GetModelById(string PercentId)
        {
            return percentdal.GetModelById(PercentId);
        }

        /// <summary>
        /// 根据竞赛id来获取符合条件的个数
        /// </summary>
        /// <param name="ConId">竞赛id</param>
        /// <returns>返回个数</returns>
        public int GetCountByConId(string ConId)
        {
            return percentdal.GetCountByConId(ConId);
        }

        /// <summary>
        /// 通过竞赛id来删除相应的数据
        /// </summary>
        /// <param name="ConId">竞赛id</param>
        /// <returns>返回bool值</returns>
        public bool DeleteByConId(string ConId)
        {
            BLL.ParticipantService participantservice = new ParticipantService();
            participantservice.ReSetPAR_AWARDS(ConId);
            return percentdal.DeleteByConId(ConId)>0;
        }
    }
}
